Mathematica 1. del

Delo z Mma

2^10

2^100

FactorInteger[%]

%%+1

PrimeQ[%]

FactorInteger[%%]

2^1000

PrimeQ[%+1]

Sqrt[2]

N[%]

N[%%,1000]

%^2-2

Uporabniške funkcije

Zgled: harmonična števila

1+1/2+1/3+1/4+1/5

H[n_]:=Sum[1/k,{k,1,n}]

H[5]

Table[H[n],{n,1,20}]

N[%]

ListPlot[%]

ListPlot[%%,Joined->True]

Plot[Log[x],{x,1,20}]

Show[%,%%,PlotRange->All]

Table[N[H[n]-Log[n]],{n,1,20}]

Table[N[H[n]-Log[n]],{n,5001,5020}]

N[EulerGamma]

Harmonična števila reda k

H[n_,r_]:=Sum[1/k^r,{k,1,n}]

H[5,1]

H[5,2]

H[n,1]

H[n,2]

H[Infinity,1]

H[Infinity,2]

Seznami

s={a,b,c,d,e}

First[s]

Last[s]

Rest[s]

Take[s,3]

Take[s,-3]

Drop[s,3]

Drop[s,-3]

Reverse[s]

Length[s]

Join[s,{1,2,3}]

Partition[s,2]

Partition[s,2,1]

Partition[s,2,3]

s[[2]]

s[[-1]]

t={1,2,3,4,5}

s+t

2s

s+1

s t

s.t

Range[100]

Select[%,OddQ]

Select[%%,PrimeQ]

Length[%]

SteviloPrastevilDo[n_]:=Length[Select[Range[n],PrimeQ]]

SteviloPrastevilDo[100]

SteviloPrastevilDo[1000]

SteviloPrastevilDo[10000]

SteviloPrastevilDo[1000000]

Notranja sintaksa izrazov

a+b

FullForm[%]

FullForm[(a+b)(c+d)]

FullForm[a-b]

FullForm[a/b]

FullForm[(a+b)/(a-b)]

InputForm[%]

StandardForm[%]

TraditionalForm[%]

FullForm[Sqrt[x]]

s

FullForm[s]

x=a+b+c+d+e

FullForm[x]

First[x]

Rest[x]

Reverse[x]

izraz=f[a,b,c]

Length[izraz]

Head[izraz]

izraz[[1]]

izraz[[2]]

izraz[[3]]

izraz[[0]]

First[izraz]

Rest[izraz]

Take[izraz,2]

AtomQ[izraz]